package proprietary

import (
	"context"
	"github.com/brocaar/lorawan"
	"network/v3/internal/models"
)

type proprietaryContext struct {
	ctx context.Context

	RXPacket    models.RXPacket
	DataPayload *lorawan.DataPayload
}

// Handle handles a proprietary uplink frame.
func Handle(ctx context.Context, rxPacket models.RXPacket) error {
	pctx := proprietaryContext{
		ctx:      ctx,
		RXPacket: rxPacket,
	}

	return HandleRunTasks(&pctx)
}

func HandleRunTasks(pctx *proprietaryContext) error {
	for _, task := range tasks {
		if err := task(pctx); err != nil {
			return err
		}
	}

	return nil
}
